﻿
--|--------------------------------------------------------------------------------
--| [GetEntityByID] - Insert Procedure Script for Entity
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[GetEntityPhoto]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
  DROP PROCEDURE [dbo].[GetEntityPhoto]
GO

CREATE PROCEDURE [dbo].[GetEntityPhoto]
(
	@Login nvarchar(50),
	@Password nvarchar(50),
	@ID int
)
AS
	SET NOCOUNT ON

	SELECT
		[Photo]
	FROM [Entity] E
	JOIN [Team] T ON E.TeamID = T.ID
	JOIN [User] U ON U.TeamID = T.ID
	WHERE
		U.[Login] = @Login AND U.[Password] = @Password
		AND E.[ID] = @ID
GO
 